package com.hxy.platform.admin.service.impl;

import com.hxy.platform.admin.dao.EmployeeMapper;
import com.hxy.platform.admin.pojo.Employee;
import com.hxy.platform.admin.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 获取所有员工
     * @return
     */
    @Override
    public List<Employee> getAllEmployee() {
        return employeeMapper.getAll();
    }

    /**
     * 添加员工
     * @param employee
     * @return
     */
    @Override
    public int addEmployee(Employee employee) {
        Employee newEmployee = new Employee();
        newEmployee.setUsername(employee.getUsername());
        newEmployee.setEmail(employee.getEmail());
        newEmployee.setGender(employee.getGender());
        newEmployee.setPhone(employee.getPhone());
        newEmployee.setPosit(employee.getPosit());
        newEmployee.setWeibo(employee.getWeibo());
        newEmployee.setStatus("目前在职");
        return employeeMapper.insertSelective(newEmployee);
    }

    /**
     * 删除员工信息
     * @param id
     * @return
     */
    @Override
    public int deleteEmployeeById(Integer id) {
        return employeeMapper.deleteByPrimaryKey(id);
    }
}
